<template>
	<view class="">
		<!-- <u-checkbox-group :max="1" @change="checkboxGroupChange"> -->
			<view class="seletbox"  v-for="(item,index) in listarr" :key="index" @click="select(item)">
				<view class="box">
					<view class="userifo">
						<text>{{item.name}}</text>
						<text>{{item.phone}}</text>
						<text class="moren" v-if="item.is_default==1">默认</text>
					</view>
					<view class="ad">
						{{item.address}}
					</view>
				</view>
				<!-- <view class="rightbox">
					<u-checkbox @change="checkboxChange(item)" v-model="item.checked" :name="item.name"
						shape="circle" active-color="#ff3333">
					</u-checkbox>
				</view> -->
			</view>
		<!-- </u-checkbox-group> -->
		<view class="addsitebox">
			<view class="addsite" @click="compile('a')">
				+ 新增地址
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getaddresslist,
	} from "../../api/api/index.js"
	export default {
		data() {
			return {
				name: "",
				listarr: [],
				value: '0',
			}
		},
		methods: {
			// 选择默认地址
			checkboxChange(v) {
				console.log(v)
			},
			// 选择发货地址
			select(v){
				uni.showLoading({
					title:"加载中"
				})
				uni.setStorageSync("selectsite",v)
				setTimeout(function(){
					uni.hideLoading()
					uni.navigateBack({
						delta:1
					})
				},1000)
			},
			// 编辑地址
			compile(v) {
				this.jumpLink({
					link: "/pages/compilesite/index",
					query: {
						id: v
					}
				})

			},
			// 接口
			public() {
				getaddresslist().then(res => {
					this.listarr = res.data.map(v => {
						v.checked = false
						return v
					})
				})
			},
		},
		onLoad() {

		},
		onShow() {
			this.public()
		}
	}
</script>

<style scoped lang="scss">
	.seletbox{
		display: flex;
		align-items: center;
		width: 710rpx;
		justify-content: space-between;
		background-color: #FFFFFF;
		border-radius: 10rpx;
		margin-left: 20rpx;
		margin-bottom: 10rpx;
		padding: 40rpx 21rpx 21rpx 21rpx;
		margin-top: 20rpx;
	}
	.box {
		

		.userifo {
			display: flex;
			align-items: center;
			font-family: MicrosoftYaHei-Bold;
			font-size: 26rpx;
			color: #282828;
			font-weight: 700;
			margin-bottom: 20rpx;

			text {
				margin-right: 20rpx;
			}

			.moren {
				display: block;
				width: 82rpx;
				height: 30rpx;
				background-color: #ff5400;
				border-radius: 15rpx;
				text-align: center;
				line-height: 30rpx;
				color: #FFFFFF;
				font-family: MicrosoftYaHei;
				font-size: 22rpx;
			}
		}

		.ad {
			font-family: MicrosoftYaHei;
			font-size: 22rpx;
			color: #282828;
			margin-bottom: 20rpx;
		}

		.hr {
			width: 100%;
			height: 1rpx;
			background-color: #dfdfdf;
		}

		.btn {
			margin-top: 20rpx;

			.rightbox {
				float: left;
				display: flex;
				align-items: center;

				text {
					font-family: MicrosoftYaHei;
					font-size: 22rpx;
					color: #666666;
					margin-left: 10rpx;
				}
			}

			.leftbox {
				float: right;
				display: flex;
				align-items: center;
				margin-top: 5rpx;

				.smallbox {
					display: flex;
					align-items: center;
					margin-left: 50rpx;

					image {
						width: 32rpx;
						height: 32rpx;
					}

					text {
						margin-left: 15rpx;
					}
				}
			}
		}

		.btn:after {
			content: '';
			display: block;
			clear: both;
		}
	}

	.addsitebox {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: #FFFFFF;
		height: 109rpx;
		padding-top: 20rpx;
		box-sizing: border-box;

		.addsite {
			width: 586rpx;
			height: 70rpx;
			background-color: #ff3333;
			border-radius: 35rpx;
			text-align: center;
			line-height: 70rpx;
			margin: 0 auto;
			font-family: MicrosoftYaHei;
			font-size: 26rpx;
			color: #ffffff;
		}
	}
</style>
